package com.lantosec.hmrp.modules.warning.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.lantosec.hmrp.core.mvc.BaseEntity;
import com.lantosec.hmrp.modules.eval.entity.EvalItem;
import com.lantosec.hmrp.modules.warning.vo.WarningDataVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 预警数据 实体类
 * </p>
 *
 * @author AutoCode
 * @since 2020-05-27
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class WarningData extends BaseEntity<WarningDataVO> {

    private static final long serialVersionUID = 1L;
    public WarningData(WarningDataVO vo){
        this.dataId = vo.getDataId();
        this.ruleId = vo.getRuleId();
        this.runTime = vo.getRunTime();
        this.dataTime = vo.getDataTime();
        this.content = vo.getContent();
        this.thresholdContent = vo.getThresholdContent();
        this.handleUserId = vo.getHandleUserId();
        this.handleUser = vo.getHandleUser();
        this.handleTime = vo.getHandleTime();
        this.handleRemark = vo.getHandleRemark();
        this.reportedUserId = vo.getReportedUserId();
        this.reportedUser = vo.getReportedUser();
        this.reportedTime = vo.getReportedTime();
        this.reportedRemark = vo.getReportedRemark();
        this.violateFlag = vo.getViolateFlag();
        this.handleState = vo.getHandleState();
        this.repeatFilterContent = vo.getRepeatFilterContent();
        this.startDate = vo.getStartDate();
        this.endDate = vo.getEndDate();
        this.tableDefine = vo.getTableDefine();
        this.warningRuleEvals = vo.getWarningRuleEvals();
        this.warningEvalNotes = vo.getWarningEvalNotes();
    }

    @Override
    public WarningDataVO convertToVO(){
        return new WarningDataVO(this);
    }


    /**
     * 预警数据ID
     */
    @TableId(value = "data_id", type = IdType.AUTO)
    private Integer dataId;

    /**
     * 预警规则
     */
    private String ruleId;

    /**
     * 预警运行时间
     */
    private String runTime;

    /**
     * 预警数据时间(从数据源中指定时间字段)
     */
    private String dataTime;

    /**
     * 预警运行的数据内容
     */
    private String content;

    /**
     * 重置数据内容
     */
    private String thresholdContent;

    /**
     * 处置人ID
     */
    private String handleUserId;

    /**
     * 处置人
     */
    private String handleUser;

    /**
     * 处置时间
     */
    private Date handleTime;

    /**
     * 处置说明
     */
    private String handleRemark;

    /**
     * 上报接收人ID
     */
    private String reportedUserId;

    /**
     * 上报接收人
     */
    private String reportedUser;

    /**
     * 上报时间
     */
    private Date reportedTime;

    /**
     * 上报处理意见
     */
    private String reportedRemark;

    /**
     * 是否违规
     */
    private Integer violateFlag;

    /**
     * 处置状态(0待处置 1待审批 2处置驳回 4已处置)
     */
    private Integer handleState;

    /**
     * 重复过滤字段数据内容
     */
    private String repeatFilterContent;


    /**
     * 开始时间
     */
    @TableField(exist = false)
    private String startDate;

    /**
     * 结束时间
     */
    @TableField(exist = false)
    private String endDate;

    /**
     * 预警数据表格定义
     */
    @TableField(exist = false)
    private String tableDefine;

    /**
     * 预警处置标准
     */
    @TableField(exist = false)
    private List<EvalItem> warningRuleEvals;

    /**
     * 处置奖惩记录
     */
    @TableField(exist = false)
    private List<WarningEvalNote> warningEvalNotes;


    public enum ColName {
        data_id, rule_id, run_time, data_time, content, threshold_content, handle_user_id, handle_user, handle_time, handle_remark, reported_user_id, reported_user, reported_time, reported_remark, violate_flag, handle_state, repeat_filter_content, 
    }
}
